﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WuShuaXinShanChu.aspx.cs" Inherits="_20160627AJAX项目学习._06AJAX无刷新删除.WuShuaXinShanChu1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script src="../Js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript">
        $(function () {

            $("input[isremoverow=true]").click(function () {
                var $this = $(this);
                var id = $(this).attr("curId");
                $.post("WuShuaXinShanChu.ashx", { "id": id }, function (data,status) {
                    if (status == "success") {
                        alert("删除成功！");
                        $this.parent().parent().remove();       //取得父亲的父亲元素删除
                    } else {
                        alert("删除失败！" + status);
                    }
                });
            });

        });

    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div>

            <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="_20160627AJAX项目学习.DAL.DataSetPostTableAdapters.T_PostTableAdapter"></asp:ObjectDataSource>
            <asp:ListView ID="ListView1" runat="server" DataKeyNames="Id" DataSourceID="ObjectDataSource1">
                <EmptyDataTemplate>
                    <table runat="server" style="">
                        <tr>
                            <td>未返回数据。</td>
                        </tr>
                    </table>
                </EmptyDataTemplate>

                <ItemTemplate>
                    <tr style="">
                        <td>
                            <asp:Label ID="IdLabel" runat="server" Text='<%# Eval("Id") %>' />
                        </td>
                        <td>
                            <asp:Label ID="IPAddrLabel" runat="server" Text='<%# Eval("IPAddr") %>' />
                        </td>
                        <td>
                            <asp:Label ID="MessageLabel" runat="server" Text='<%# Eval("Message") %>' />
                        </td>
                        <td>
                            <asp:Label ID="PostDateLabel" runat="server" Text='<%# Eval("PostDate") %>' />
                        </td>
                        <td>
                            <input type="button" isremoverow="true" curId='<%# Eval("Id") %>' value="AJAX删除" /></td>
                    </tr>
                </ItemTemplate>
                <LayoutTemplate>
                    <table runat="server">
                        <tr runat="server">
                            <td runat="server">
                                <table id="itemPlaceholderContainer" runat="server" border="0" style="">
                                    <tr runat="server" style="">
                                        <th runat="server">编号</th>
                                        <th runat="server">IP地址</th>
                                        <th runat="server">消息</th>
                                        <th runat="server">上传时间</th>
                                        <th runat="server">操作</th>
                                    </tr>
                                    <tr id="itemPlaceholder" runat="server">
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr runat="server">
                            <td runat="server" style=""></td>
                        </tr>
                    </table>
                </LayoutTemplate>
            </asp:ListView>
        </div>
    </form>
</body>
</html>
